package com.qfedu.openplateform.token;

import io.jsonwebtoken.Claims;
import io.jsonwebtoken.Jwts;

/**
 * @author lileijian
 * @create 2021-12-04 16:34
 */
public class TokenTestParse {

    public static void main(String[] args) {
        String token="eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOiJhZG1pbiIsImlhdCI6MTYzODYwNjY4OCwiZXhwIjoxNjM4NjEwMjg4LCJpZCI6MSwicXVhbnhpYW4iOiJBRE1JTiJ9.74JL4HIOYWq02r6r-VFPOVqBBydAr1vCTESpqO-PXT8";
        // Claims 就是封装的所有用户信息
        Claims body = Jwts.parser().setSigningKey("meiyoumima".getBytes()).parseClaimsJws(token).getBody();

        // 解析得到用户信息

        String subject = body.getSubject();
        Object id = body.get("id");
        Object quanxian = body.get("quanxian");

            System.out.println("subject = " + subject);
            System.out.println("id = " + id);
            System.out.println("quanxian = " + quanxian);

    }
}
